from http import HTTPStatus
# dashscope sdk >= 1.22.1
from dashscope import VideoSynthesis
import os
from dotenv import load_dotenv

load_dotenv()


def sample_sync_call_t2v(user_input):
    # call sync api, will return the result
    # print('please wait...')
    rsp = VideoSynthesis.call(model='wan2.2-t2v-plus',
                              api_key=os.getenv('DASHSCOPE_API_KEY'),
                              prompt=user_input,
                              size='1920*1080')
    print(rsp)
    if rsp.status_code == HTTPStatus.OK:
        return rsp.output.video_url
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))


if __name__ == '__main__':
    print("请输入想要生成视频的画面：")
    users_input = input()
    sample_sync_call_t2v(users_input)